'use strict';

module.exports = app => {
  const { router, controller, middleware } = app;

  const adminRouter = router.namespace('/api/v1/access');

  // WEB权限相关
  adminRouter.get('/signout', controller.v1.access.web.signout); // --后台登出
  adminRouter.post('/signin', controller.v1.access.web.signin); // --后台登入
  adminRouter.get('/captcha', controller.v1.access.web.captcha); // --后台获取验证码
  adminRouter.put('/password', controller.v1.access.web.password); // --后台修改密码
  adminRouter.get('/current', middleware.authHandler(), controller.v1.access.web.current); // --后台获取个人信息
  adminRouter.resources('serviceGeeTest', '/service/geeTest', controller.v1.service.geeTest);

  adminRouter.resources('goods', '/goods', middleware.authHandler(), controller.v1.goods.index);
  adminRouter.resources('goodsUsers', '/goods/:goodsId/users', middleware.authHandler(), controller.v1.goods.users);
  adminRouter.resources('uploads', '/uploads', middleware.authHandler(), controller.v1.uploads.index);

  adminRouter.resources('users', '/users', middleware.authHandler(), controller.v1.admin.users.index);
  adminRouter.resources('usersIntegrals', '/users/:userId/integrals', middleware.authHandler(), controller.v1.admin.users.integrals);
  adminRouter.resources('usersGoods', '/users/:userId/goods', middleware.authHandler(), controller.v1.admin.users.goods);

  adminRouter.resources('apply', '/apply', middleware.authHandler(), controller.v1.admin.apply.index);
  adminRouter.resources('banners', '/banners', middleware.authHandler(), controller.v1.admin.banners.index);
  adminRouter.resources('questions', '/questions', middleware.authHandler(), controller.v1.admin.questions.index);
  adminRouter.resources('feedbacks', '/feedbacks', middleware.authHandler(), controller.v1.admin.feedbacks.index);
};